extends Control
class_name  BattleAnimAttrBar

@onready var redBar: TextureProgressBar = $TextureProgressBarRed
@onready var blueBar: TextureProgressBar = $TextureProgressBarBlue

var growTargetValue
var isGrowing = false
var currentBar = null
		

func setValue(v):
	currentBar.value = v
	

func grow2Value(v):
	growTargetValue = v
	isGrowing = true
	
	
func setRed():
	redBar.show()
	blueBar.hide()
	currentBar = redBar
	

func setBlue():
	redBar.hide()
	blueBar.show()
	currentBar = blueBar
	
	
func _physics_process(delta: float) -> void:
	processGrowing()
	

func processGrowing():
	if not isGrowing: return
	
	currentBar.value = GlobalUtils.fMoveTowards(currentBar.value, growTargetValue, 1)
	if currentBar.value >= growTargetValue:
		currentBar.value = growTargetValue
		isGrowing = false
	
